package app.web.galgame.cgs.anaylse;

import java.io.File;

public class GalCollectsChange {
	
	public static String folderPath = "H:/待处理/CHANGE";
	
	public static String cutString(String name,char begin,char end){
		
		StringBuffer sb = new StringBuffer();
		boolean flag = true;
		for(int i=0;i<name.length();i++){
			char active = name.charAt(i);
			
			if(active == begin){
				flag = false;
			}else if(active == end){
				flag = true;
			}else{
				if(flag){
					sb.append(active);
				}
			}
			
		}
		
		return sb.toString();
		
	}
	
	public static void analyse(){
		
		File folder = new File(folderPath);
		for(File childFolder:folder.listFiles()){
			
			if(childFolder.isDirectory()){
				
				String fileName = cutTitle(childFolder.getName());
				
				System.out.println(folderPath+"/"+fileName);
				
				childFolder.renameTo(new File(folderPath+"/"+fileName));
				
			}
			
		}
		
	}
	
	public static String cutTitle(String title){
		
		String tmpTitle = title;
		tmpTitle = cutString(tmpTitle, '(', ')');
		tmpTitle = cutString(tmpTitle, '[', ']');
		tmpTitle = tmpTitle.trim();
		if("".equals(tmpTitle)){
			return title;
		}		
		return tmpTitle;
	}
	
	public static void main(String[] args) {
		GalCollectsChange.analyse();
	}
	
}
